#include <iostream>
#include <memory>
#include <string>
#include <array>

using namespace std;


/*
\ brief:  迭代器抽象类
\ author: 清晨与猫鱼
*/
class Iterator {
public:
    virtual bool hasNext() = 0;     // 是否存在下一个
    virtual string* next() = 0;     // 获取
};


/*
\ brief:  容器
\ author: 清晨与猫鱼
*/
class Container {
public:
    virtual Iterator* getIterator()  = 0;
};


/*
\ brief:  存储库名称
\ author: 清晨与猫鱼
*/
class NameRepository 
    : public Container {

/*
\ brief:  内部类  存储类迭代器
\ author: 清晨与猫鱼
*/
    class NameIterator  
        : public Iterator {
    public:
    explicit NameIterator(NameRepository* object) 
        : object_(object), index_(0){
    }

    bool hasNext() {
        return index_ < object_->names.size();
    }

    string* next() {
        if (hasNext()) {
            return &object_->names[index_++];
        }
        return nullptr;
    }
    private:
        int index_;
        NameRepository* object_;        // 存储器引用
    };

public:

/*
\ brief:   返回存储器的迭代器
\ author: 清晨与猫鱼
*/
    Iterator* getIterator() {
        return new NameIterator(this);
    }
  
private:
    array<string, 4> names{"Robert" , "John" ,"Julie" , "Lora"};        // 存储器数据
};


